package com.sqx.modules.gameChat.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sqx.common.utils.PageUtils;
import com.sqx.common.utils.Result;
import com.sqx.modules.gameChat.dao.ChatContentTcwmDao;
import com.sqx.modules.gameChat.entity.ChatContentTcwm;
import com.sqx.modules.gameChat.service.ChatContentTcwmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class ChatContentTcwmServiceImpl extends ServiceImpl<ChatContentTcwmDao, ChatContentTcwm> implements ChatContentTcwmService {

    @Autowired
    private ChatContentTcwmDao chatContentTcwmDao;

    @Override
    public PageUtils selectChatContentPage(Integer page, Integer limit, Long chatConversationId, String content) {
        return new PageUtils(baseMapper.selectChatContentPage(new Page<>(page,limit),chatConversationId,content));
    }

    @Override
    public int updateChatContentStatusByUserIdAndChatId(Long userId,Long chatConversationId){
        return baseMapper.updateChatContentStatusByUserIdAndChatId(userId, chatConversationId);
    }

    @Override
    public int selectChatCount(Long userId) {
        return baseMapper.selectChatCount(userId);
    }

    @Override
    public Result selectOrdersChatPage(Integer page, Integer limit, Long userId, Long riderId, Long shopId) {
        Page<ChatContentTcwm> pages = new Page(page, limit);
        PageUtils pageUtils = new PageUtils(chatContentTcwmDao.selectOrdersChatPage(pages, userId, riderId, shopId));
        return Result.success().put("data", pageUtils);
    }

    @Override
    public Result selectGameChatDetails(Integer page, Integer limit, Long ordersId){
        Page<ChatContentTcwm> pages = new Page<>(page, limit);
        IPage<ChatContentTcwm> chatContentTcwmIPage = chatContentTcwmDao.selectGameChatDetails(pages, ordersId);
        PageUtils pageUtils = new PageUtils(chatContentTcwmIPage);
        return Result.success().put("data", pageUtils);
    }

}